package com.hk.webapp.service.impl;

import com.hk.webapp.bean.SysRole;
import com.hk.webapp.dao.SysRoleMapper;
import com.hk.webapp.vo.PageVo;
import com.hk.webapp.service.SysRoleService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

@Service
@Transactional(readOnly = true, rollbackFor = Exception.class)
public class SysRoleServiceImpl implements SysRoleService {

    @Resource
    private SysRoleMapper sysRoleMapper;

    @Override
    public SysRole getEntityById(Integer id) {
        return sysRoleMapper.selectByPrimaryKey(id);
    }

    @Override
    public List<SysRole> getEntityList() {
        return sysRoleMapper.getEntityList();
    }

    @Override
    public List<SysRole> getEntityByIds(List<Integer> ids) {
        return sysRoleMapper.getEntityByIds(ids);
    }

    @Override
    public PageInfo<SysRole> getPageList(PageVo vo) {
        PageHelper.startPage(vo.getPageIndex(),vo.getPageSize());
        List<SysRole> list=sysRoleMapper.getPageList();
        PageInfo<SysRole> plist=new PageInfo<>(list);
        return plist;
    }

    @Override
    public int getCount() {
        return sysRoleMapper.getCount();
    }

    @Override
    @Transactional
    public int update(SysRole sysRole) {
        return sysRoleMapper.updateByPrimaryKeySelective(sysRole);
    }

    @Override
    @Transactional
    public int insert(SysRole sysRole) {
        return sysRoleMapper.insertSelective(sysRole);
    }
}
